<? $menu_name = array('','Admin Group','Admin User','Bank','Banners','Contact List','Compatible Products','Member','News','Newsletter','Order','Product Category','Product','Promotion Coupon','Shipping Rate','Transfer List','Stock Alert');?>
<? //$this->db->debug = true;?>
<table width="100%" class="ui-state-default">
<tr>
	<td height="30px">
			<div id="smoothmenu1" class="ddsmoothmenu ">
			<ul class="menu">
				<li><a href="admin_profiles/">ยินดีต้อนรับ  <?=login_data('name');?></a></li>				
			<? 
			$admin_menu = $this->db->getarray("SELECT * FROM admin_menu where pid = 0 order by order_no ");
			foreach($admin_menu as $item):			
				$have_sub = $this->db->getone("Select count(*) FROM admin_menu WHERE pid=".$item['id']);
				if($have_sub > 0){
					echo '<li><a href="'.$item['url'].'">'.$item['title'].'</a>';
						echo '<ul class="ui-state-default">';
						$admin_submenu = $this->db->getarray("SELECT * FROM admin_menu where pid = ".$item['id']." order by order_no ");
						foreach($admin_submenu as $sitem):
						if(@permission($sitem['id'],'canview')){
						 	echo '<li><a href="'.$sitem['url'].'">'.$sitem['title'].'</a></li>';
						 } 	
						endforeach;
						echo '</ul>';
					echo '</li>';
				}else{
				 if(@permission($item['id'],'canview')){
				 	echo '<li><a href="'.$item['url'].'">'.$item['title'].'</a></li>';
				 } 
				}
			 endforeach; 
			?>	
			<li><a href="admin/signout">ออกจากระบบ</a></li>				
			</ul>			
			</div>			
	</td>
</tr>
</table>